#pragma once

#include <base.h>

static inline word_t rdcnt_relax()
{
	unsigned int lo,hi;
	asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
	return ((word_t)hi << 32) | (word_t)lo;
}
/* FIXME: 由于流水线和超前执行，可能不精确 */
static inline word_t rdcnt()
{
	// unsigned int lo, hi;
	// asm volatile(
	// 	"RDTSCP\n\t" /*read the clock*/
	// 	"mov %%edx, %0\n\t"
	// 	"mov %%eax, %1\n\t"
	// 	"CPUID\n\t"
	// 	: "=r"(hi), "=r"(lo)::"%rax", "%rbx", "%rcx", "%rdx");
	// return ((word_t)hi << 32) | (word_t)lo;
	return rdcnt_relax();
}
